package com.star.domain;

import com.sun.istack.internal.NotNull;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import javax.persistence.*;
import java.util.Set;

/**
 * site配置信息
 *
 * @author 孙星阳
 * @date 2017/9/27 下午3:32
 */
@Entity
@Getter
@Setter
@ToString
@Table(name = "conf_page_site")
public class PageSite extends AbstractEntity {

    @NotNull
    @Column(name = "domain", nullable = false, length = 50)
    private String domain;
    @Column(name = "userAgent", columnDefinition = "varchar(255) ")
    private String userAgent;
    @Column(name = "defaultCookies", columnDefinition = "varchar(1000)")
    private String defaultCookies;
    @Column(name = "charset", columnDefinition = "varchar(10) default 'utf-8'")
    private String charset;
    @Column(name = "sleepTime", columnDefinition = "int default 500")
    private Integer sleepTime;
    @Column(name = "retryTimes", columnDefinition = "int default 3")
    private int retryTimes;
    @Column(name = "cycleRetryTimes", columnDefinition = "int default 1")
    private int cycleRetryTimes;
    @Column(name = "timeOut", columnDefinition = "int default 10000")
    private Integer timeOut;
    @Column(name = "headers", columnDefinition = "varchar(1000)")
    private String headers;

    /**
     * 是否需要登录判断表达式
     */
    @Column(name = "loginJudgeExpression", columnDefinition = "varchar(200)")
    private String loginJudgeExpression;
    /**
     * 验证码页面判断表达式
     */
    @Column(name = "captchaJudgeExpression", columnDefinition = "varchar(200)")
    private String captchaJudgeExpression;

    /**
     * 自动登录Js脚本文件名称
     */
    @Column(name = "loginJsFileName", columnDefinition = "varchar(200)")
    private String loginJsFileName;
    /**
     * 验证码识别Js脚本文件名称
     */
    @Column(name = "captchaJsFileName", columnDefinition = "varchar(200)")
    private String captchaJsFileName;


    public Integer getSleepTime() {
        if (sleepTime == null)
            return 0;
        else
            return sleepTime;
    }

}
